package com.jemmyee.core.entity;
// default package

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "core_message")
public class Message extends BaseEntity implements java.io.Serializable {

	// Fields
	private String id;
	private Integer fromId;
	private Integer toId; //toId=0 表示管理员发送给所有人的
	private String title;
	private String content;
	private String sendIp;
	private String reply;
	private String replyIp;
	private Date addTime;
	private Short isDelete;
	
	
	private User fromUser;
	private User toUser;
	// 关系映射
	@ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
	@JoinColumn(name = "from_id", insertable = false, updatable = false, nullable = true)
	public User getFromUser() {
		return fromUser;
	}

	public void setFromUser(User fromUser) {
		this.fromUser = fromUser;
	}

	// 关系映射
	@ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
	@JoinColumn(name = "to_id", insertable = false, updatable = false, nullable = true)
	public User getToUser() {
		return toUser;
	}

	public void setToUser(User toUser) {
		this.toUser = toUser;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "from_id")
    public Integer getFromId() {
		return fromId;
	}

	public void setFromId(Integer fromId) {
		this.fromId = fromId;
	}
	@Column(name = "to_id")
	public Integer getToId() {
		return toId;
	}

	public void setToId(Integer toId) {
		this.toId = toId;
	}
	
	@Column(name = "title",length=50)
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "content",length=255)
	public String getContent() {
		return this.content;
	}

	

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "send_ip", length = 20)
	public String getSendIp() {
		return this.sendIp;
	}

	public void setSendIp(String sendIp) {
		this.sendIp = sendIp;
	}

	@Column(name = "reply")
	public String getReply() {
		return this.reply;
	}

	public void setReply(String reply) {
		this.reply = reply;
	}

	@Column(name = "reply_ip", length = 20)
	public String getReplyIp() {
		return this.replyIp;
	}

	public void setReplyIp(String replyIp) {
		this.replyIp = replyIp;
	}

	@Column(name = "add_time", length = 0)
	public Date getAddTime() {
		return this.addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	@Column(name = "is_delete")
	public Short getIsDelete() {
		return this.isDelete;
	}

	public void setIsDelete(Short isDelete) {
		this.isDelete = isDelete;
	}

}